<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiAdminMenuTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_admin_menu';

    /**
     * Run the migrations.
     * @table qii_admin_menu
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id')->comment('菜单ID');
            $table->string('title', 50)->default('')->comment('标题');
            $table->unsignedInteger('pid')->default('0')->comment('上级分类ID');
            $table->unsignedInteger('sort')->default('0')->comment('排序（同级有效）');
            $table->char('url', 255)->default('')->comment('链接地址');
            $table->unsignedTinyInteger('hide')->default('0')->comment('是否隐藏');
            $table->string('tip')->default('')->comment('提示');
            $table->string('group', 50)->nullable()->default('')->comment('分组');
            $table->string('icon', 50)->nullable()->default('')->comment('ICON');
            $table->unsignedTinyInteger('is_dev')->default('0')->comment('是否仅开发者模式可见');
            $table->char('install_token', 35)->default('')->comment('安装识别码(用于模块自动安装及卸载菜单)');

            $table->index(["pid"], 'pid');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
